package com.jielin.handling.controller.caseassociation;

import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageInfo;
import com.jielin.handling.Annotation.MyPower;
import com.jielin.handling.bean.AppResult;
import com.jielin.handling.entity.vo.CaseasSociationVo;
import com.jielin.handling.page.DataGrid;
import com.jielin.handling.service.caseassociation.AVCorrelationService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * Created by cz on 2019-04-03.
 */
@RestController
@RequestMapping("/av/")
@Slf4j
@MyPower(name = "执法音视频关联模块", url = "/av", isPublic = true)
public class CaseasSociationController {
	@Autowired
	AVCorrelationService service;



	/**
	 * 执法音视频关联率
	 * 
	 * @param policeId 警员id
	 * @return
	 */
	@MyPower(name = "执法音视频关联率", url = "/aVRelation", isPublic = true)
	@RequestMapping("aVRelation")
	public AppResult aVRelation(String policeId) {
		log.info("policeId:{}", JSONObject.toJSONString(policeId));
		AppResult appResult = new AppResult();
		JSONObject date = new JSONObject();
		List<CaseasSociationVo> list = service.aVRelation(policeId);
		if (list.size() > 0) {
			date.put("value", list);
			appResult.setCode(200);
			appResult.setMsg("查询关联执法音视频成功!");
			appResult.setData(date);
		} else {
			date.put("value", 0);
			appResult.setCode(-1);
			appResult.setMsg("查询关联执法音视频失败!");
			appResult.setData(date);
		}
		return appResult;
	}
}
